package day05;
//求数组的最大值和最小值

import java.util.Arrays;

public class MaxOfArray {
    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100);

            System.out.println(arr[i]);
        }
        int min = arr[0];
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i];
            }
            if (arr[i] > max) {
                max = arr[i];
            }

        }
        System.out.println("最小值是:" + min);
        System.out.println("最大值是:" + max);
        arr = Arrays.copyOf(arr, arr.length + 1);
        arr[arr.length-1] = max;
        System.out.println(arr[10]);

        /*

        int max = arr[0];
        if (arr[1]>max){
            max=arr[i];
        }
        System.out.println("最小值是:" + min);

        int max = arr[0];

        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
            System.out.println(arr[i]);

        }
        System.out.println("最大值是:" + max);
        //System.out.println("最小值是:" + max);

         */

    }
}
